#ifndef MACRO_HELPER_H
#define MACRO_HELPER_H
#include <QObject>

#define SINGLETON(x)     \
private: \
    x(x const&); \
    void operator=(x const&); \
 public: \
 static x* getInstance() \
 { \
    static x *instance = new x(); \
    return instance; \
 } \
  private:

#define QML_WRITABLE_PROPERTY(type, name, func_name) \
    protected: \
        Q_PROPERTY (type name READ get##func_name WRITE set##func_name NOTIFY name##Changed) \
        type m_##name; \
    public: \
        type get##func_name () const { \
            return m_##name ; \
        } \
    public Q_SLOTS: \
        bool set##func_name (type name) { \
            bool ret = false; \
            if ((ret = m_##name != name)) { \
                m_##name = name; \
                emit name##Changed (m_##name); \
            } \
            return ret; \
        } \
    Q_SIGNALS: \
        void name##Changed (type name); \
    private:

 #define QML_READONLY_PROPERTY(type, name, func_name) \
     protected: \
         Q_PROPERTY (type name READ get##func_name NOTIFY name##Changed) \
         type m_##name; \
     public: \
         type get##func_name () const { \
             return m_##name ; \
         } \
         bool update##func_name (type name) { \
             bool ret = false; \
             if ((ret = m_##name != name)) { \
                 m_##name = name; \
                 emit name##Changed (m_##name); \
             } \
             return ret; \
         } \
     Q_SIGNALS: \
         void name##Changed (type name); \
    private:

#endif // MACRO_HELPER_H
